﻿using System;
using System.Collections.Generic;
using ProjScan.Modules;
using ProjScan.RecordManager.AssetData;
using ProjScan.Submodules.Shader_Analysis;
using ProjScan.Submodules.Shader_Analysis.Build;
using ProjScan.Tools;

namespace ProjScan.RecordManager
{
	// Token: 0x02000289 RID: 649
	internal class ShaderBuildInfoRecordManager : RecordManagerBase<ShaderBuildInfoAssetData>
	{
		// Token: 0x06001128 RID: 4392 RVA: 0x00050990 File Offset: 0x0004EB90
		public override void PrepareAssets()
		{
			Singleton<PerformanceMeasurer>.Instance.StartStateExecutionMeasure("BuiltShader");
			ScanLog.Instance.LogInfo(Module.Effects_Play_Check, ScanLog.Stage.s3, this.TableTag, "Scan");
			this.datas = new List<ShaderBuildInfoAssetData>();
			ToolsHelper.ShowProgressBar(this.TableTag, "Preparing shader data...", 0.5f, false);
			ShaderOptimizationHandler.OptimizeShaders();
			this.ActiveAllRecord();
			Singleton<ShaderInfoManager>.Instance.buildInfoList.ForEach(new Action<ShaderBuildInfo>(this.AddShaderBuildInfoAssetData));
			Singleton<PerformanceMeasurer>.Instance.StopStateExecutionMeasure((long)this.datas.Count);
		}

		// Token: 0x06001129 RID: 4393 RVA: 0x00050A28 File Offset: 0x0004EC28
		private void AddShaderBuildInfoAssetData(ShaderBuildInfo shaderBuildInfo)
		{
			ShaderBuildInfoAssetData shaderBuildInfoAssetData = new ShaderBuildInfoAssetData(shaderBuildInfo);
			shaderBuildInfoAssetData.id = this.datas.Count;
			try
			{
				this.ValidateAsset(shaderBuildInfoAssetData);
			}
			catch (Exception ex)
			{
				ScanLog.Instance.LogInfo(ScanLog.LogLevel.EXCEPTION, Module.Shader_Analysis, this.TableTag + "," + shaderBuildInfoAssetData.simpleName, string.Concat(new string[]
				{
					(ex.GetType() == null) ? null : ex.GetType().ToString(),
					"\n",
					ex.Message,
					"\n",
					ex.StackTrace
				}));
			}
			shaderBuildInfoAssetData.Reset();
			this.datas.Add(shaderBuildInfoAssetData);
		}

		// Token: 0x17000385 RID: 901
		// (get) Token: 0x0600112A RID: 4394 RVA: 0x00050AF4 File Offset: 0x0004ECF4
		public override string TableTag
		{
			get
			{
				return "built_shader";
			}
		}
	}
}
